package design.demos.order.state.impl;

import design.demos.order.enums.StateEnum;
import design.demos.order.bo.Order;
import design.demos.order.service.OrderDataBaseService;
import design.demos.order.state.OrderState;

import java.util.UUID;

public class OrderPending extends OrderState {

    OrderDataBaseService orderService = new OrderDataBaseService();

    @Override
    public Order orderPending(Order order) {
        System.out.println("新建订单进入待处理状态逻辑");
        order.setId(UUID.randomUUID().toString());
        order.setState(StateEnum.ORDER_PENDING.value);
        orderService.addOrder(order);
        return order;
    }

    @Override
    public Order orderProcessing(Order order) {
        System.out.println("待处理-->进行中 逻辑处理中...");
        order.setState(StateEnum.ORDER_PROCESSING.value);
        orderService.updateOrder(order);
        return order;
    }
}
